document.querySelector('.img__btn').addEventListener('click', function () {
    document.querySelector('.content').classList.toggle('s--signup')
    $('#registerFormClearBtn').click()
    $('#loginFormClearBtn').click()
})

function register() {
    const name = $('#name').val();
    const phone = $('#phone').val();
    const code = $('#code').val();
    const password = $('#password').val();
    $.ajax({
        url: "/user/do/register",
        type: "post",
        data: {
            name:name,
            phone:phone,
            code:code,
            password:password
        },
        dataType: "json",
        success: function (response) {
            let code = response.code;
            if (code == 0) {
                layer.msg("注册成功! 3s后跳转到登录页面", {icon: 1, offset: "auto", time: 3000});
                setTimeout(function () {
                    location.reload(true);
                }, 3000);
            } else {
                layer.msg("注册失败! " + response.code + " " + response.msg, {icon: 0, offset: "auto", time: 2000});
            }
        },
        error: function (response) {
            layer.msg("注册失败! " + response.status + " " + response.statusText, {
                icon: 0,
                offset: "auto",
                time: 2000
            });
        }
    });
}